/**
 * teJinternalFrame initially created by Jon Axford
 * Listeners added by Jon.
 * All look and feel elements (GUI) added by Dagny 
 */

package teComponents;


import java.awt.Toolkit;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.LineBorder;

import Forms.MainMDIForm;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class teJinternalFrame extends javax.swing.JInternalFrame {
	

	/**
	* Auto-generated main method to display this JFrame
	*/
	 /*public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				teJFrame inst = new teJFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}*/
	
	/**
	 * function to create an imageicon created by Dagny Jackson
	 * to use a custom graphic (later as a logo in a label)
	 * Returns an ImageIcon, or null if the path was invalid.
	 */ 
	protected ImageIcon createAnImageIcon(String path, String description) {
	    java.net.URL imgURL = getClass().getResource(path);
	    if (imgURL != null) {
	        return new ImageIcon(imgURL, description);
	    } else {
	        System.err.println("The following file was not found: " + path);
	        return null;
	    }
	}
	
	
	
	protected teJFrame myMDIParent;
	private teJinternalFrame mySelf =this;
	public teJinternalFrame() {
		super();
		initGUI();
		myMDIParent=null;
	}
	public teJinternalFrame(teJFrame MDIParent)
	{//Jon
		super();
		initGUI();
		myMDIParent=MDIParent;
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setBackground(new java.awt.Color(251,253,242));
			getContentPane().setLayout(null);
			getContentPane().setForeground(new java.awt.Color(43,32,3));
			this.setClosable(true);
			//this.setMaximizable(true);
			//this.setIconifiable(true);
			this.setResizable(true);
			
			/**
			 * Look and Feel added by Dagny Jackson
			 */
			//change the look and feel of the teJinternalFrame
			UIManager.put("InternalFrame.inactiveTitleBackground", new java.awt.Color(43,32,3)); //dark dark brown
			UIManager.put("InternalFrame.activeTitleBackground", new java.awt.Color(2,234,231)); //aqua blue
			
			UIManager.put("InternalFrame.inactiveTitleForeground", new java.awt.Color(251,253,242)); //light green
			UIManager.put("InternalFrame.activeTitleForeground", new java.awt.Color(43,32,3)); //dark dark brown
			
			UIManager.put("InternalFrame.border", new LineBorder(new java.awt.Color(43,32,3), 2, true));

			UIManager.put("InternalFrame.activeBorderColor", new java.awt.Color(43,32,3)); //dark dark brown
			UIManager.put("InternalFrame.inactiveBorderColor", new java.awt.Color(43,32,3)); //dark dark brown
			
			UIManager.put("InternalFrame.titlePaneHeight", 200);
			
			//create the icons to replace the default ones for minimizing, maximizing the internal frame
			ImageIcon closeIcon = createAnImageIcon("/Images/cancel.png", "Exit");
			//ImageIcon iconifyMinIcon = createAnImageIcon("/Images/world_delete.png", "Minimize");
			ImageIcon icon = createAnImageIcon("/Images/world.png", "Travel Experts");
			//ImageIcon maximizeIcon = createAnImageIcon("/Images/world_add.png", "Maximize");
			
			//place the new icons in place of the old ones
			UIManager.put("InternalFrame.closeIcon", closeIcon);
			UIManager.put("InternalFrame.icon", icon);
			//UIManager.put("InternalFrame.iconifyIcon", iconifyMinIcon);
			//UIManager.put("InternalFrame.minimizeIcon", iconifyMinIcon);
			//UIManager.put("InternalFrame.maximizeIcon", maximizeIcon);
			
			javax.swing.plaf.basic.BasicInternalFrameUI ui = new javax.swing.plaf.basic.BasicInternalFrameUI(this);
			this.setUI(ui);
			
			
			pack();
			this.setSize(645, 389);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	WindowListener windowListener = new WindowListener() {//Jonathan Axford
		
		@Override
		public void windowOpened(WindowEvent e) {
			// TODO Auto-generated method stub
			
		}
		
		@Override
		public void windowIconified(WindowEvent e) {
			// TODO Auto-generated method stub
			
		}
		
		@Override
		public void windowDeiconified(WindowEvent e) {
			// TODO Auto-generated method stub
			
		}
		
		@Override
		public void windowDeactivated(WindowEvent e) {
			// TODO Auto-generated method stub
			
		}
		
		@Override
		public void windowClosing(WindowEvent e) {
			// TODO Auto-generated method stub
			MainMDIForm form = (MainMDIForm)myMDIParent;
			form.killer(mySelf);//Removes this window from the list of open windows
			mySelf.setVisible(false);//kills this window
			mySelf.dispose();
		}
		
		@Override
		public void windowClosed(WindowEvent e) {
			// TODO Auto-generated method stub
			
		}
		
		@Override
		public void windowActivated(WindowEvent e) {
			// TODO Auto-generated method stub
			
		}
	};
//need to write a dispose event handler --Jon
	/*
	 {
	 	if(myMDIParent!=null)
	 	{
	 		myMDIParent.killer(this);
	 	}
	 }
	 */

}
